<?php
$page_title = 'eTAT| Survey';

require_once '../../controller.php';




require_once '../../header.php';
require_once '../../classes/Survey.php';
print "<br>";
if(isset($_REQUEST['del'])){
	echo '<font color="red">Survey Deleted Sucessfully</font>';
}

if(isset($_REQUEST['copy'])){
	echo '<font color="red">Survey Copied Sucessfully</font>';
}


if(isset($_SESSION['logged_in'])){
	$instructor_id = $_SESSION['logged_in'];
}
$survey_object = new Survey();
$surveys = $instructor->getAllSurveys($instructor_id);
if($surveys){
	foreach($surveys as $i=>$value){
		$survey[] = $value;
	}
}


?>
<br></br>
<a href="createsurvey.php"><p align="right"><input type="button" name ="create_survey" value = "Create New Survey"></p></a><br>

<?php //echo'-----------------------------------------------------------------------------';
echo '<h1 align ="center">My Surveys</h1><br>';
?>
<table cellpadding="2px" cellspacing="2px">
	<tr>
		<td width="650px"><strong>Survey Name</strong></td>
		<td width="150px"><strong>Date Created</strong></td>
		<td width="150px"><strong>Last Modified </strong></td>  
	    <td width="50px"><strong>Preview</strong></td>
	    <td width="50px"><strong>Copy</strong></td>
	    <td width="50px"><strong>Edit</strong></td>
	    <td width="50px"><strong>Results</strong></td>
	    <td width="50px"><strong>Send</strong></td>
	    <td width="50px"><strong>Delete</strong></td>
	</tr>
	<tr>
		<td>&nbsp;</td>
	</tr>
	<form name="select" method="post"><?php 
	if($survey){
		foreach($survey as $i=>$value){
			
			echo "<td width ='200px'><a href='edit.php?sid=$value->id'><font color='blue'>$value->survey_name</font></a></td><td width ='100px'>$value->date_created</td>";
			if(strtotime ($value->last_modified)< strtotime($value->date_created)){
				echo "<td>Never</td>";
			}else{
				echo"<td>$value->last_modified</td>";
			}
			echo "<td> <a href='preview.php?sid=$value->id&sec=1&num=0'><img src='../../includes/images/surveyicons/preview.png'  alt='preview' ></img></a></td>";
			echo "<td><a href='copy.php?sid=$value->id'><img src='../../includes/images/surveyicons/copy.png'  alt='copy' ></img></a></td>";
			echo "<td><a href='edit.php?sid=$value->id'><img src='../../includes/images/surveyicons/edit.png'  alt='edit' ></img></a></td>";
            echo "<td><a href='result.php?sid=$value->id'><img src='../../includes/images/surveyicons/results.png'  alt='results' ></img></a></td>";
		    echo "<td><a href='schedule.php?sid=$value->id'><img src='../../includes/images/surveyicons/deliver.png'  alt='deliver' ></img></a></td>";
   			echo "<td><a href='delete.php?sid=$value->id'><img src='../../includes/images/surveyicons/delete.png'  alt='delete' ></img></a></td>";
		    
			/*$no_of_responses = $survey_object->getTotalNumberOfResponses($value->id);
			if($no_of_responses){
			echo "<td>$no_of_responses</td></tr>";
			}else{
			echo "<td>None</td>";	
			}*/

			echo "</tr>";
		}
	}
	?>
	<tr>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td>&nbsp;</td>
	</tr>
	
	
	
	</form>
</table>
<div class='clear'></div>
<?php 
require_once '../../footer.php';
?>